package top.yueyazhui.repeat_submit.controller;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.util.JSONPObject;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import top.yueyazhui.repeat_submit.annotation.RepeatSubmit;
import top.yueyazhui.repeat_submit.dto.Hello;

@RestController
@RequestMapping("/hello")
public class HelloController {

    /**
     * // @RequestBody String json 这种写法只有能读取第一行，需要一个entity
     * @param json
     * @return
     */
    @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
    @RepeatSubmit
    public String hello(@RequestBody Hello hello) {
        System.out.println("json = " + JSONObject.toJSONString(hello));
        return "yes";
    }


    @PostMapping("/2")
    @RepeatSubmit
    public String hello2(String json) {
        System.out.println("json = " + json);
        return json;
    }
}
